package zzx;

import java.util.Arrays;
import java.util.Scanner;

public class MiddleNum {

    public static void main(String[] args) {
        int n, mid, leftCout, rightCount;
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        // 输入数据
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);// 排序

        // 找出中间数
        mid = n / 2;
        leftCout = mid;
        rightCount = n - mid - 1;

        // 去掉左边与中间相同值数的个数
        for (int i = mid - 1; i >= 0; i--) {
            if (a[i] == a[mid]) {
                leftCout--;
            } else {
                break;
            }
        }

        // 去掉右边与中间相同值数的个数
        for (int i = mid + 1; i < n; i++) {
            if (a[i] == a[mid]) {
                rightCount--;
            } else {
                break;
            }
        }

        // 输出结果
        if (leftCout == rightCount) {
            System.out.print(a[mid]);
        } else {
            System.out.print(-1);
        }

        sc.close();
    }

}